package com.ytjj.qmyx.admin.controller;

import com.ytjj.common.api.CommonResult;
import com.ytjj.common.api.ResultCode;
import com.ytjj.qmyx.admin.model.request.HotelProductRequest;
import com.ytjj.qmyx.admin.service.HotelService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Description 酒店管理
 * @ClassName HotelController
 *
 *
 * @Version 1.0
 **/

@RestController
@RequestMapping("/hotel")
public class HotelController {

    @Resource
    private HotelService hotelService;


    /**
     * @Description 获取酒店商品列表
     *
     *
     *
     * @Version 1.0
     **/
    @PostMapping("/getHotelProductList")
    public CommonResult getHotelProductList(@RequestBody HotelProductRequest hotelProductRequest) {
        return CommonResult.page(hotelService.getHotelProductList(hotelProductRequest));
    }

    /**
     * @Description 搜索酒店商品
     *
     *
     *
     * @Version 1.0
     **/
    @GetMapping("/searchHotelProduct")
    public CommonResult searchHotelProduct(@RequestParam(value = "productId", required = false) Integer productId,
                                        @RequestParam(value = "productName", required = false) String productName) {
        return CommonResult.success(hotelService.searchHotelProduct(productId, productName));
    }


    /**
     * @Description 新增酒店商品
     *
     *
     *
     * @Version 1.0
     **/
    @GetMapping("/addHotelProduct")
    public CommonResult addHotelProduct(@RequestParam("productId") Integer productId,
                                        @RequestParam("type") String type,
                                        @RequestParam("sort") Integer sort,
                                        @RequestParam("status") Integer status) {
        hotelService.addHotelProduct(productId, type, sort, status);
        return CommonResult.success(ResultCode.SUCCESS);
    }

    @GetMapping("/getHotelTypeList")
    public CommonResult getHotelTypeList() {
        return CommonResult.success(hotelService.getHotelTypeList());
    }


    /**
     * @Description 更新酒店商品信息
     *
     *
     *
     * @Version 1.0
     **/
    @GetMapping("/updateHotelProduct")
    public CommonResult updateHotelProduct(@RequestParam(value = "sort", required = false) Integer sort,
                                           @RequestParam(value = "status", required = false) Integer status,
                                           @RequestParam("id") Integer id) {
        hotelService.updateHotelProduct(sort, status, id);
        return CommonResult.success(ResultCode.SUCCESS);
    }


    /**
     * @Description 删除商品
     *
     *
     *
     * @Version 1.0
     **/
    @GetMapping("deleteHotelProduct")
    public CommonResult deleteHotelProduct(@RequestParam("id") Integer id) {
        hotelService.deleteHotelProduct(id);
        return CommonResult.success(ResultCode.SUCCESS);
    }


}
